<?php
namespace App\Services\WxMass\Filter;

use App\Services\WxMass\FilterFactory;

/**
 * 制定openId列表
 * @package App\Services\Filter
 */
class FilterOpenids extends FilterAbstract
{
    /**
     * 格式化存储规则数据
     * @param $request
     * @return array
     */
    public function formatInput($request)
    {
        $this->inputType = FilterFactory::INPUT_TYPE_OPENIDS;
        $this->inputOpenids = (array) $request->filter_rule['openids'];
        if (count($this->inputOpenids) < 2){
            throw new \Exception('所提供用户openid不能少于2个');
        }
        return $this->formatInputData();
    }

    /**
     * 规则输出格式化
     * @param $rule
     * @return array
     */
    public function formatOutput($rule)
    {
        $this->outputType = FilterFactory::OUTPUT_TYPE_ALL;
        $this->outputOpenids = $rule['openids'];
        return $this->formatOutputData();
    }
}